package com.example.blog.controller;

import com.example.blog.data.UserInfoPram;
import com.example.blog.pojo.resquest.UserLoginRequest;
import com.example.blog.pojo.response.UserInfoResponse;
import com.example.blog.service.impl.UserServiceImpl;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource(name = "UserService")
    private UserServiceImpl userService;
    @RequestMapping("/login")
    public UserLoginRequest login(@Validated @RequestBody UserInfoPram userInfoPram){
        log.info("用户登入ID:{}"+userInfoPram.getUserName());
     return userService.login(userInfoPram);
    }
    @RequestMapping("/getUserInfo")
    public UserInfoResponse getUserInfo(@NotNull Integer userId){
        return userService.getUserInfo(userId);
    }
    @RequestMapping("/getAuthorInfo")
    public UserInfoResponse getAuthorInfo(@NotNull Integer blogId){
        return userService.getAuthorInfo(blogId);
    }
}
